package kr.hkit.powerjava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGeneric {
	private int[] arr;
	private static final int SIZE = 6;
	private Random rnd;
	
	public LottoGeneric() {
		arr = new int[LottoGeneric.SIZE];
		rnd = new Random();
	}
	
	public void getLottoNum() {
		int num = -1;
		for(int i = 0; i < arr.length; i++) {
			num = getNum();
			if(isFind(num)) {
				num = getNum();
				i--;
			}else {
				arr[i] = num;
			}
		}
	}
	
	public int getNum() {
		return rnd.nextInt(45) + 1;
	}
	
	public boolean isFind(int searchNum) {
		boolean isEquals = false;
		for(int i = 0; i < arr.length; i++){
			if(searchNum == arr[i]){
				isEquals = true;
				break;
			}

		}
		System.out.println(isEquals);
		return isEquals;
	}
	
	
	@Override
	public String toString() {
		return "LottoGeneric [arr=" + Arrays.toString(arr) + "]";
	}

	public static void main(String[] args) {
		LottoGeneric lo = new LottoGeneric();
		
		lo.getLottoNum();
		System.out.println(lo);
//		String result = lo.isFind(30)? "Find" : "Not found";
//		System.out.println(result);
	}
	
	
	

}
